package com.o2o.app.adapter;

import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

public class MyPagerAdapter extends PagerAdapter {
	private List<View> picViews;
	public MyPagerAdapter(List<View> picViews) {
		this.picViews = picViews;
	}

	@Override
	public boolean isViewFromObject(View view, Object object) {
		return view == object;
	}

	@Override
	public int getCount() {
		return picViews.size();
	}

	@Override
	public Object instantiateItem(View view, int position) {
		ViewPager mViewPager = (ViewPager) view;
		mViewPager.addView(picViews.get(position));
		return picViews.get(position);
	}

	@Override
	public void destroyItem(View container, int position, Object object) {
		ViewPager viewPager = (ViewPager) container;
		viewPager.removeView(picViews.get(position));
	}
}
